package com.siemens.industrial.model.admin;

import org.springframework.jdbc.core.RowMapper;

import java.util.Date;

/**
 * Created by weig on 8/23/16.
 */
public class Device {
    private String deviceId;
    private String tenantId;
    private String deviceUniqueId;
    private String model;
    private String type;
    private String group;
    private String line;
    private String purchaseDate;
    private String deviceName;
    private Date lastHeartBeat;
    private String manufacturer;
    private String description;
    private String serviceAddress;
    private String deviceImg;
    private Date deleteTime;

    private static final RowMapper<Device> rowMapper = (resultSet, i) -> {
        Device device = new Device();
        device.setDeviceId(resultSet.getString("device_id"));
        device.setTenantId(resultSet.getString("tenant_id"));
        device.setDeviceUniqueId(resultSet.getString("device_unique_id"));
        device.setModel(resultSet.getString("device_model"));
        device.setType(resultSet.getString("device_type"));
        device.setGroup(resultSet.getString("group"));
        device.setLine(resultSet.getString("line"));
        device.setDeviceName(resultSet.getString("device_name"));
        device.setLastHeartBeat(resultSet.getTimestamp("last_heartbeat_time") == null ? null : new Date(resultSet.getTimestamp("last_heartbeat_time").getTime()));
        device.setPurchaseDate(resultSet.getString("purchase_date"));
        device.setDescription(resultSet.getString("description"));
        device.setDeviceImg(resultSet.getString("device_img"));
        device.setManufacturer(resultSet.getString("device_manufactory"));
        device.setServiceAddress(resultSet.getString("service_address"));
        device.setDeleteTime(resultSet.getTimestamp("delete_time") == null ? null : new Date(resultSet.getTimestamp("delete_time").getTime()));

        return device;
    };

    public static RowMapper<Device> getRowMapper() {
        return rowMapper;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDeviceUniqueId() {
        return deviceUniqueId;
    }

    public void setDeviceUniqueId(String deviceUniqueId) {
        this.deviceUniqueId = deviceUniqueId;
    }

    public void setServiceAddress(String serviceAddress) {
        this.serviceAddress = serviceAddress;
    }

    public String getServiceAddress() {
        return this.serviceAddress;
    }

    public void setDeleteTime(Date deleteTime) {
        this.deleteTime = deleteTime;
    }

    public Date getDeleteTime() {
        return this.deleteTime;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getLine() {
        return line;
    }

    public void setLine(String line) {
        this.line = line;
    }

    public String getPurchaseDate() {
        return purchaseDate;
    }

    public void setPurchaseDate(String purchaseDate) {
        this.purchaseDate = purchaseDate;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public Date getLastHeartBeat() {
        return lastHeartBeat;
    }

    public void setLastHeartBeat(Date lastHeartBeat) {
        this.lastHeartBeat = lastHeartBeat;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDeviceImg() {
        return deviceImg;
    }

    public void setDeviceImg(String deviceImg) {
        this.deviceImg = deviceImg;
    }
}
